/**
 * @author LKQ
 * @date 2021/12/21 9:32
 * @description 注意闰年的判断方式：是400的倍数，或者是4的倍数但不是100的倍数。
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.dayOfYear("2004-03-01"));
    }

    public int dayOfYear(String date) {

        int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int year = Integer.parseInt(date.substring(0, 4)),
                month = Integer.parseInt(date.substring(5, 7)),
                day = Integer.parseInt(date.substring(8,10));
        if ( (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            // 闰年，那么2月为29天
            days[1] = 29;
        }
        int ans = 0;
        for(int i = 0; i < month - 1; i++) {
            ans += days[i];
        }
        return ans + day;

    }
}
